﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Text;
using System.Reflection;
using SDT.DataService;

namespace SDT.DataService.Contexts
{
    /// <summary>
    /// Kết nối database : System Spider
    /// </summary>
    public class PageContext : SystemSpiderDataContext
    {
        #region Function UC
        [Function(Name = "dbo.InsertPage")]
        public int InsertPage([Parameter(Name = "SiteID", DbType = "Int")] System.Nullable<int> siteID,
            [Parameter(Name = "SourceCategoryID", DbType = "Int")] System.Nullable<int> sourceCategoryID,
            [Parameter(Name = "Url", DbType = "NVarChar(500)")] string url,
              [Parameter(Name = "LinkImageDesc", DbType = "NVarChar(600)")] string imgDes, 
            [Parameter(Name = "Name", DbType = "NVarChar(500)")] string name, 
            [Parameter(DbType = "VarChar(50)")] string wID)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), siteID, sourceCategoryID, url,imgDes, name, wID);
            return (int)(result.ReturnValue);
        }

        [Function(Name = "dbo.UpdatePage")]
        public int UpdatePage([Parameter(Name = "PageID", DbType = "Int")] System.Nullable<int> pageID, [Parameter(Name = "Name", DbType = "NVarChar(500)")] string name)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), pageID, name);
            return ((int)(result.ReturnValue));
        }
        #endregion

        #region Function WC

        [Function(Name = "dbo.sp_WC_PageChangeStatus")]
        public int sp_WC_PageChangeStatus([Parameter(Name = "PageId", DbType = "Int")] System.Nullable<int> pageId, [Parameter(Name = "Status", DbType = "TinyInt")] System.Nullable<byte> status)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), pageId, status);
            return ((int)(result.ReturnValue));
        }

        [Function(Name = "dbo.sp_WC_Pages_Count_List")]
        public int sp_WC_Pages_Count_List([Parameter(Name = "CateId", DbType = "Int")] System.Nullable<int> cateId, [Parameter(Name = "Status", DbType = "VarChar(20)")] string status, [Parameter(DbType = "TinyInt")] System.Nullable<byte> nRetryFrom, [Parameter(DbType = "TinyInt")] System.Nullable<byte> nRetryTo)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), cateId, status, nRetryFrom, nRetryTo);
            return ((int)(result.ReturnValue));
        }

        [Function(Name = "dbo.sp_WC_Pages_SelectByID")]
        public ISingleResult<sp_WC_Pages_SelectByIDResult> sp_WC_Pages_SelectByID([Parameter(Name = "PageId", DbType = "Int")] System.Nullable<int> pageId)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), pageId);
            return ((ISingleResult<sp_WC_Pages_SelectByIDResult>)(result.ReturnValue));
        }

        [Function(Name = "dbo.sp_WC_Pages_SelectList")]
        public ISingleResult<sp_WC_Pages_SelectListResult> sp_WC_Pages_SelectList([Parameter(Name = "CateId", DbType = "Int")] System.Nullable<int> cateId, [Parameter(Name = "Status", DbType = "VarChar(20)")] string status, [Parameter(DbType = "TinyInt")] System.Nullable<byte> nRetryFrom, [Parameter(DbType = "TinyInt")] System.Nullable<byte> nRetryTo, [Parameter(Name = "PageSize", DbType = "SmallInt")] System.Nullable<short> pageSize, [Parameter(Name = "PageNo", DbType = "Int")] System.Nullable<int> pageNo)
        {
            IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), cateId, status, nRetryFrom, nRetryTo, pageSize, pageNo);
            return ((ISingleResult<sp_WC_Pages_SelectListResult>)(result.ReturnValue));
        }

        #endregion

    }
}
